using System;
using UnityEngine;

public class HexaCoordinate : BlockCoordinate
{
	public int width
	{
		get
		{
			return this._width;
		}
		set
		{
			this._width = value;
		}
	}

	public int height
	{
		get
		{
			return this._height;
		}
		set
		{
			this._height = value;
		}
	}

	public float size
	{
		get
		{
			return this._size;
		}
		set
		{
			this._size = value;
		}
	}

	public float SizeX
	{
		get
		{
			return this.size;
		}
	}

	public float SizeY
	{
		get
		{
			return this.size * 0.866f;
		}
	}

	public bool Contains(Point point)
	{
		return point.x >= 0 && point.x < this.width && point.y >= 0 && point.y < this.height;
	}

	public Point IndexToPuzzle(int index)
	{
		Point result;
		result.x = index % this.width;
		result.y = index / this.width;
		return result;
	}

	public Point IndexToPuzzle(int _index, int _width, int _height)
	{
		Point result;
		result.x = _index % _width;
		result.y = _index / _width;
		return result;
	}

	public int PuzzleToIndex(int x, int y)
	{
		return x + y * this.width;
	}

	public int PuzzleToIndex(Point point)
	{
		return this.PuzzleToIndex(point.x, point.y);
	}

	public Point WorldToPuzzle(Vector3 position)
	{
		Point result;
		result.x = (int)Mathf.Round(position.x / (this.SizeX * 0.75f) + (float)this.width / 2f - 0.5f);
		if (result.x % 2 == 0)
		{
			result.y = (int)Mathf.Round(position.y / this.SizeY + (float)this.height / 2f - 0.5f);
		}
		else
		{
			result.y = (int)Mathf.Round((position.y - this.SizeY / 2f) / this.SizeY + (float)this.height / 2f - 0.5f);
		}
		return result;
	}

	public Vector3 PuzzleToWorld(Point point)
	{
		return this.PuzzleToWorld((float)point.x, (float)point.y);
	}

	public Vector3 PuzzleToWorld(float x, float y)
	{
		Vector3 zero = Vector3.zero;
		zero.x = (x - (float)this.width / 2f + 0.5f) * this.SizeX * 0.75f;
		if (x % 2f == 0f)
		{
			zero.y = (y - (float)this.height / 2f + 0.5f) * this.SizeY;
		}
		else
		{
			zero.y = (y - (float)this.height / 2f + 0.5f) * this.SizeY + this.SizeY / 2f;
		}
		zero.z = 0f;
		return zero;
	}

	public int _width = 5;

	public int _height = 5;

	public float _size = 2f;
}
